<%@page import="com.entity.ProType"%>
<%@page import="com.biz.ProTypeBizImpl"%>
<%@page import="com.entity.UserInfo"%>
<%@page import="com.biz.ProductBizImpl"%>
<%@page import="com.entity.Product"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>商品列表</title>
    
	<meta charset="UTF-8">
    <meta name="keywords" content="keyword1,keyword2,keyword3">
    <meta name="description" content="this is my page">
    <meta name="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="css/showtable.css">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
	<script type="text/javascript">
		function delPro( delid ){
			var flag=confirm("确定要删除吗?");
			if(flag){
				location="admin/product/doDel?id="+delid;
			}
		}
		
		function checkall(){
			var flag=document.getElementById("all").checked;
			var checks=document.getElementsByName("check");
			for(var i=0;i<checks.length;i++){
				checks[i].checked=flag;
			}
		}
		
		function delManyPro(){
			if(confirm("确定要删除这些商品吗？")){
				$("#delManyForm").submit();
			}
		}
	</script>
  </head>
  <body>
  	<div class="main-body-div">
  		<form action="admin/product/do/doDelManyPro.jsp" method="post" id="delManyForm">
		  	<h2 class="title-table">商品列表</h2>
		  	<div class="title-link">
		  		<a href="admin/product/addPro.jsp">增加商品</a>
		  		<a href="javascript:delManyPro()">删除指定商品</a>
		  	</div>
		  	<table>
		  		<tr>
		  			<td><input type="checkbox" id="all" onclick="checkall()"/>编号</td>
		  			<td>名称</td>
		  			<td>价格</td>
		  			<td>库存</td>
		  			<td>类别</td>
		  			<td>操作</td>
		  		</tr>
		    <%	
		    	List<Product> list=new ProductBizImpl().showPro(null);
		    	for(Product p:list){
		    %>
		   		<tr>
		   			<td><input type="checkbox" name="check" value="<%=p.getId()%>"/><%=p.getId()%></td>
		   			<td><%=p.getPname()%></td>
		   			<td><%=p.getPrice()%></td>
		   			<td><%=p.getStock()%></td>
		   			<td><%=p.getKindName()%></td>
		   			<td>
		   				<a href="javascript:delPro(<%=p.getId()%>)">删除</a>
		   				&nbsp;|&nbsp;
		   				<a href="admin/product/getpro?id=<%=p.getId()%>">修改</a>
		   			</td>
		   		</tr>
		    <%
		    	}
		    %>
		    </table>
	    </form>
	 </div>
  </body>
</html>
